﻿using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;

namespace Keyki.XNAGameEngine.Common.Console
{
	//binds keys to characters or strings
	internal struct KeyBinding
	{
		public string AltString;
		public string ShiftAltString;
		public string ShiftString;
		public string UnmodifiedString;

		public KeyBinding(string unmodifiedString, string shiftString, string altString, string shiftAltString)
		{
			UnmodifiedString = unmodifiedString;
			ShiftString = shiftString;
			AltString = altString;
			ShiftAltString = shiftAltString;
		}
	}

	//defines standard character mappings
	internal class KeyboardHelper
	{
		public static Dictionary<Keys, KeyBinding> ItalianBindings = new Dictionary<Keys, KeyBinding>
		                                                             	{
		                                                             		{Keys.OemPipe, new KeyBinding("\\", "|", "", "")},
		                                                             		{Keys.OemBackslash, new KeyBinding("<", ">", "", "")},
		                                                             		{
		                                                             			Keys.OemOpenBrackets,
		                                                             			new KeyBinding("\"", "?", "", "")
		                                                             			},
		                                                             		{
		                                                             			Keys.OemCloseBrackets,
		                                                             			new KeyBinding("м", "^", "", "")
		                                                             			},
		                                                             		{Keys.OemSemicolon, new KeyBinding("и", "й", "[", "{")},
		                                                             		{Keys.OemPlus, new KeyBinding("+", "*", "]", "}")},
		                                                             		{Keys.OemTilde, new KeyBinding("т", "з", "@", "")},
		                                                             		{Keys.OemQuotes, new KeyBinding("а", "°", "#", "")},
		                                                             		{Keys.OemQuestion, new KeyBinding("щ", "§", "", "")},
		                                                             		{Keys.OemComma, new KeyBinding(", ", ";", "", "")},
		                                                             		{Keys.OemPeriod, new KeyBinding(".", ":", "", "")},
		                                                             		{Keys.OemMinus, new KeyBinding("-", "_", "", "")},
		                                                             		{Keys.Space, new KeyBinding(" ", "", "", "")},
		                                                             		{Keys.Tab, new KeyBinding("\t", "", "", "")},
		                                                             		{Keys.D1, new KeyBinding("1", "!", "", "")},
		                                                             		{Keys.D2, new KeyBinding("2", "@", "", "")},
		                                                             		{Keys.D3, new KeyBinding("3", "#", "", "")},
		                                                             		{Keys.D4, new KeyBinding("4", "$", "", "")},
		                                                             		{Keys.D5, new KeyBinding("5", "%", "", "")},
		                                                             		{Keys.D6, new KeyBinding("6", "^", "", "")},
		                                                             		{Keys.D7, new KeyBinding("7", "&", "", "")},
		                                                             		{Keys.D8, new KeyBinding("8", "*", "", "")},
		                                                             		{Keys.D9, new KeyBinding("9", "(", "", "")},
		                                                             		{Keys.D0, new KeyBinding("0", ")", "", "")},
		                                                             		{Keys.NumPad1, new KeyBinding("1", "!", "", "")},
		                                                             		{Keys.NumPad2, new KeyBinding("2", "\"", "", "")},
		                                                             		{Keys.NumPad3, new KeyBinding("3", "Ј", "", "")},
		                                                             		{Keys.NumPad4, new KeyBinding("4", "$", "", "")},
		                                                             		{Keys.NumPad5, new KeyBinding("5", "%", "Ђ", "")},
		                                                             		{Keys.NumPad6, new KeyBinding("6", "&", "", "")},
		                                                             		{Keys.NumPad7, new KeyBinding("7", "/", "", "")},
		                                                             		{Keys.NumPad8, new KeyBinding("8", "(", "", "")},
		                                                             		{Keys.NumPad9, new KeyBinding("9", ")", "", "")},
		                                                             		{Keys.NumPad0, new KeyBinding("0", "=", "", "")},
		                                                             		{Keys.A, new KeyBinding("a", "A", "", "")},
		                                                             		{Keys.B, new KeyBinding("b", "B", "", "")},
		                                                             		{Keys.C, new KeyBinding("c", "C", "", "")},
		                                                             		{Keys.D, new KeyBinding("d", "D", "", "")},
		                                                             		{Keys.E, new KeyBinding("e", "E", "Ђ", "")},
		                                                             		{Keys.F, new KeyBinding("f", "F", "", "")},
		                                                             		{Keys.G, new KeyBinding("g", "G", "", "")},
		                                                             		{Keys.H, new KeyBinding("h", "H", "", "")},
		                                                             		{Keys.I, new KeyBinding("i", "I", "", "")},
		                                                             		{Keys.J, new KeyBinding("j", "J", "", "")},
		                                                             		{Keys.K, new KeyBinding("k", "K", "", "")},
		                                                             		{Keys.L, new KeyBinding("l", "L", "", "")},
		                                                             		{Keys.M, new KeyBinding("m", "M", "", "")},
		                                                             		{Keys.N, new KeyBinding("n", "N", "", "")},
		                                                             		{Keys.O, new KeyBinding("o", "O", "", "")},
		                                                             		{Keys.P, new KeyBinding("p", "P", "", "")},
		                                                             		{Keys.Q, new KeyBinding("q", "Q", "", "")},
		                                                             		{Keys.R, new KeyBinding("r", "R", "", "")},
		                                                             		{Keys.S, new KeyBinding("s", "S", "", "")},
		                                                             		{Keys.T, new KeyBinding("t", "T", "", "")},
		                                                             		{Keys.U, new KeyBinding("u", "U", "", "")},
		                                                             		{Keys.V, new KeyBinding("v", "V", "", "")},
		                                                             		{Keys.W, new KeyBinding("w", "W", "", "")},
		                                                             		{Keys.X, new KeyBinding("x", "X", "", "")},
		                                                             		{Keys.Y, new KeyBinding("y", "Y", "", "")},
		                                                             		{Keys.Z, new KeyBinding("z", "Z", "", "")},
		                                                             		{Keys.Enter, new KeyBinding("", "", "", "")} //"\n"
		                                                             	};

		public static Dictionary<Keys, KeyBinding> AmericanBindings = new Dictionary<Keys, KeyBinding>
		                                                              	{
		                                                              		{Keys.OemPipe, new KeyBinding("\\", "|", "", "")},
		                                                              		{Keys.OemBackslash, new KeyBinding("\\", "|", "", "")},
		                                                              		{
		                                                              			Keys.OemOpenBrackets,
		                                                              			new KeyBinding("[", "{", "", "")
		                                                              			},
		                                                              		{
		                                                              			Keys.OemCloseBrackets,
		                                                              			new KeyBinding("]", "}", "", "")
		                                                              			},
		                                                              		{Keys.OemSemicolon, new KeyBinding(";", ":", "", "")},
		                                                              		{Keys.OemPlus, new KeyBinding("=", "+", "", "")},
		                                                              		{Keys.OemTilde, new KeyBinding("`", "~", "", "")},
		                                                              		{Keys.OemQuotes, new KeyBinding("\"", "\"", "", "")},
		                                                              		{Keys.OemQuestion, new KeyBinding("/", "?", "", "")},
		                                                              		{Keys.OemComma, new KeyBinding(", ", "<", "", "")},
		                                                              		{Keys.OemPeriod, new KeyBinding(".", ">", "", "")},
		                                                              		{Keys.Decimal, new KeyBinding(".", "", "", "")},
		                                                              		{Keys.OemMinus, new KeyBinding("-", "_", "", "")},
		                                                              		{Keys.Space, new KeyBinding(" ", "", "", "")},
		                                                              		{Keys.Tab, new KeyBinding("    ", "", "", "")},
		                                                              		// font can't use \t so I manually put 4 spaces
		                                                              		{Keys.D1, new KeyBinding("1", "!", "", "")},
		                                                              		{Keys.D2, new KeyBinding("2", "@", "", "")},
		                                                              		{Keys.D3, new KeyBinding("3", "#", "", "")},
		                                                              		{Keys.D4, new KeyBinding("4", "$", "", "")},
		                                                              		{Keys.D5, new KeyBinding("5", "%", "", "")},
		                                                              		{Keys.D6, new KeyBinding("6", "^", "", "")},
		                                                              		{Keys.D7, new KeyBinding("7", "&", "", "")},
		                                                              		{Keys.D8, new KeyBinding("8", "*", "", "")},
		                                                              		{Keys.D9, new KeyBinding("9", "(", "", "")},
		                                                              		{Keys.D0, new KeyBinding("0", ")", "", "")},
		                                                              		{Keys.NumPad1, new KeyBinding("1", "!", "", "")},
		                                                              		{Keys.NumPad2, new KeyBinding("2", "@", "", "")},
		                                                              		{Keys.NumPad3, new KeyBinding("3", "#", "", "")},
		                                                              		{Keys.NumPad4, new KeyBinding("4", "$", "", "")},
		                                                              		{Keys.NumPad5, new KeyBinding("5", "%", "", "")},
		                                                              		{Keys.NumPad6, new KeyBinding("6", "^", "", "")},
		                                                              		{Keys.NumPad7, new KeyBinding("7", "&", "", "")},
		                                                              		{Keys.NumPad8, new KeyBinding("8", "*", "", "")},
		                                                              		{Keys.NumPad9, new KeyBinding("9", "(", "", "")},
		                                                              		{Keys.NumPad0, new KeyBinding("0", ")", "", "")},
		                                                              		{Keys.A, new KeyBinding("a", "A", "", "")},
		                                                              		{Keys.B, new KeyBinding("b", "B", "", "")},
		                                                              		{Keys.C, new KeyBinding("c", "C", "", "")},
		                                                              		{Keys.D, new KeyBinding("d", "D", "", "")},
		                                                              		{Keys.E, new KeyBinding("e", "E", "", "")},
		                                                              		{Keys.F, new KeyBinding("f", "F", "", "")},
		                                                              		{Keys.G, new KeyBinding("g", "G", "", "")},
		                                                              		{Keys.H, new KeyBinding("h", "H", "", "")},
		                                                              		{Keys.I, new KeyBinding("i", "I", "", "")},
		                                                              		{Keys.J, new KeyBinding("j", "J", "", "")},
		                                                              		{Keys.K, new KeyBinding("k", "K", "", "")},
		                                                              		{Keys.L, new KeyBinding("l", "L", "", "")},
		                                                              		{Keys.M, new KeyBinding("m", "M", "", "")},
		                                                              		{Keys.N, new KeyBinding("n", "N", "", "")},
		                                                              		{Keys.O, new KeyBinding("o", "O", "", "")},
		                                                              		{Keys.P, new KeyBinding("p", "P", "", "")},
		                                                              		{Keys.Q, new KeyBinding("q", "Q", "", "")},
		                                                              		{Keys.R, new KeyBinding("r", "R", "", "")},
		                                                              		{Keys.S, new KeyBinding("s", "S", "", "")},
		                                                              		{Keys.T, new KeyBinding("t", "T", "", "")},
		                                                              		{Keys.U, new KeyBinding("u", "U", "", "")},
		                                                              		{Keys.V, new KeyBinding("v", "V", "", "")},
		                                                              		{Keys.W, new KeyBinding("w", "W", "", "")},
		                                                              		{Keys.X, new KeyBinding("x", "X", "", "")},
		                                                              		{Keys.Y, new KeyBinding("y", "Y", "", "")},
		                                                              		{Keys.Z, new KeyBinding("z", "Z", "", "")},
		                                                              		{Keys.Enter, new KeyBinding("", "", "", "")} //"\n"
		                                                              	};
	}
}